// import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { getApiList } from '../server'
import type { RootObject, AreaTree, ChinaAdd, ChinaTotal, StatisGradeCityDetail } from './type'

export const useStore = defineStore('counter', {
  state: () => ({
    list: <RootObject>{},
    item: <AreaTree[]>[],
    chainAdd: <ChinaAdd>{},
    chainTotal: <ChinaTotal>{},
    cityDetail: <StatisGradeCityDetail[]>[]
  }),
  getters: {

  },
  actions: {
    async getList() {
      const res = await getApiList()
      // console.log(res);
      const random = Math.floor(Math.random() * 10)
      this.list = res.data.data
      // console.log(this.list);
      this.chainAdd = this.list.diseaseh5Shelf.chinaAdd
      this.chainTotal = this.list.diseaseh5Shelf.chinaTotal
      this.cityDetail = this.list.statisGradeCityDetail.slice(random, random + 10)
    }
  }
})
